//
//  WarGameDecks.m
//  WarGame
//
//  Created by iD Student on 6/27/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "WarGameDecks.h"

//Private Interface
@interface WarGameDecks()

@property (nonatomic, strong) NSMutableArray * fullDeck;
@property (nonatomic, strong) NSMutableArray * playerDeck;
@property (nonatomic, strong) NSMutableArray * botDeck;


@end


//Implementation
@implementation WarGameDecks

@synthesize fullDeck = _fullDeck;

-(NSMutableArray *) fullDeck
{
    if (!_fullDeck) {
        _fullDeck = [NSMutableArray arrayWithCapacity:52];
        for (int i = 0; i<52; i++) {
            [_fullDeck addObject: [NSNumber numberWithInt:i]];
        }
    }

    return _fullDeck;
}


@synthesize playerDeck = _playerDeck;
@synthesize botDeck = _botDeck;


//Shuffle Full Deck Code
-(void) shuffleFullDeck
{
    
    //Loops Through Deck
    for (int i =0; i<51; i++) {
        [self.fullDeck exchangeObjectAtIndex:i withObjectAtIndex:arc4random_uniform(51-i)+i];
    }
    NSRange pl = NSMakeRange(0, 26);
    NSRange bo = NSMakeRange(26, 26);
    self.playerDeck= [[self.fullDeck subarrayWithRange:pl] mutableCopy];
    self.botDeck = [[self.fullDeck subarrayWithRange:bo] mutableCopy];
}



//Player Deck
-(int)pullFromTopOfPlayerDeck;
{
    int num = [[self.playerDeck objectAtIndex:0] intValue ];
    [self.playerDeck removeObjectAtIndex:0];
    return num;
    
}


-(void)putOnBottomOfPlayerDeck: (int)num;
{
    [self.playerDeck addObject:[NSNumber numberWithInt:num]];
}


-(int)getPlayerDeckSize;
{
    int num = [self.playerDeck count];
    return num;
    
}



//Bot Deck
-(int)pullFromTopOfBotDeck;
{
    int num = [[self.botDeck objectAtIndex:0] intValue ];
    [self.botDeck removeObjectAtIndex:0];
    return num;
    
}


-(void)putOnBottomOfBotDeck: (int)num;
{
    [self.botDeck addObject:[NSNumber numberWithInt:num]];
}


-(int)getPBotDeckSize;
{
    int num = [self.botDeck count];
    return num;
    
}



@end
